﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Claro.QuestionModel
{
    public class clsTipoGrupos
    {
        public static DataTable SelecionarTipos()
        {
            SqlConnection cn = clsConexao.Conectar();
            SqlCommand cmd = cn.CreateCommand();
            cmd.CommandText = "SELECT codTipo, nmTipo from TipoNomeGrupos";
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            DataTable dt = new DataTable();
            da.Fill(dt);

            cn.Close();
            cn.Dispose();
            return dt;
        }

        public static List<string> SelecionarNomesGrupos(int codTipoGrupo)
        {
            SqlConnection cn = clsConexao.Conectar();
            SqlCommand cmd = cn.CreateCommand();
            cmd.CommandText = "SELECT nmGrupo from NomeGrupos where codTipo = @codTipo";
            cmd.Parameters.Add("@codTipo", SqlDbType.Int).Value = codTipoGrupo;
            SqlDataReader dr = cmd.ExecuteReader();
            List<string> nomes = new List<string>();
            while (dr.Read())
            {
                nomes.Add(dr["nmGrupo"].ToString());
            }

            cn.Close();
            cn.Dispose();
            return nomes;
        }
    }
}
